package cn.comtom.ewbs.signature.common.vo.request;

import java.io.Serializable;

import com.alibaba.fastjson.annotation.JSONField;

import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;

/**     
 * 分页类
 * @author: liuhy
 * @date:   2021/09/13
 *   
 */
@ToString
public class PageRequest implements Serializable{

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
     * 排序分隔符
     */
    public static final String ORDER_BY_SEPARATOR = ",";

    /**
     * 页数
     */
    @ApiModelProperty(value = "当前页数", required = true,example = "1")
    @JSONField(ordinal = 3)
    private long page;

    /**
     * 分页大小
     */
    @ApiModelProperty(value = "分页大小", required = true,example = "10")
    @JSONField(ordinal = 4)
    private long limit;

    @ApiModelProperty(value = "降序字段,多个字段逗号分隔")
    @JSONField(ordinal = 5)
    private String descFields;

    @ApiModelProperty(value = "升序字段,多个字段逗号分隔")
    @JSONField(ordinal = 6)
    private String ascFields;
    
    @ApiModelProperty(value = "分组字段,多个字段逗号分隔")
    @JSONField(ordinal = 7)
    private String groupFields;

    public long getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public long getLimit() {
        return limit == 0 ? 10 : limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }


    public long offset() {
        return (page - 1) * limit;
    }

    public String getDescFields() {
        return descFields;
    }

    public void setDescFields(String descFields) {
        this.descFields = descFields;
    }

    public String getAscFields() {
        return ascFields;
    }

    public void setAscFields(String ascFields) {
        this.ascFields = ascFields;
    }

    public String getGroupFields() {
        return groupFields;
    }

    public void setGroupFields(String groupFields) {
        this.groupFields = groupFields;
    }

    public void setPage(long page) {
        this.page = page;
    }

    public void setLimit(long limit) {
        this.limit = limit;
    }

}
